package com.fancy.service.impl;

import com.fancy.dao.IMusicDao;
import com.fancy.pojo.BaseResult;
import com.fancy.pojo.category.Album;
import com.fancy.pojo.category.Music;
import com.fancy.pojo.dto.MusicDto;
import com.fancy.service.MusicService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MusicServiceImpl implements MusicService {
    @Autowired
    IMusicDao musicDao;
    @Override
    public List<Music> selectAllMusic() {
        return musicDao.selectAllMusic();
    }

    @Override
    public MusicDto selectMusicById(Integer id) {
        return musicDao.selectMusicById(id);
    }

    @Override
    public List<MusicDto> selectMusicByAlbumId(Integer id) {
        return musicDao.selectMusicByAlbumId(id);
    }

    @Override
    public List<MusicDto> findAllMusic() {
        return musicDao.findAllMusic();
    }

    @Override
    public PageInfo<MusicDto> findAllMusicPage(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        List<MusicDto> musicDtoList = findAllMusic();
        PageInfo<MusicDto> musicPageInfo= new PageInfo(musicDtoList);
        return musicPageInfo;
    }

    @Override
    public PageInfo<Music> findMusicListByPage(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        List<Music> musicList= selectAllMusic();
        PageInfo<Music> musicPageInfo= new PageInfo<>(musicList);

        return musicPageInfo;
    }

    @Override
    public List<Music> findMusicByName(String musicName) {
        return musicDao.findMusicByName(musicName);
    }

    @Override
    public List<Music> getMusicById(Map map) {

        return musicDao.getMusicById((Integer) map.get("musicTypeId"),(Integer)map.get("singerId"),(Integer)map.get("languageId"));

    }

    @Override
    public Music findMusicById(Integer id) {
        return musicDao.findMusicById(id);
    }

    @Override
    public List<MusicDto> findMusicByTypeId(Integer id) {
        return musicDao.findMusicByTypeId(id);
    }

    @Override
    public List<MusicDto> findMusicByLanguageId(Integer id) {
        return musicDao.findMusicByLanguageId(id);
    }


//    @Override
//    public List<Music> getMusicById(Integer musicTypeId, Integer singerId, Integer languageId) {
//        return musicDao.getMusicById(musicTypeId,singerId,languageId);
//    }

}
